<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>FullScreenTest</title>
    <style>
        body{
            background-color:gray;
        }
        .box {
            width: 200px;
            height: 150px;
            line-height: 150px;
            text-align: center;
            background-color: orange;
            position: absolute;
            top: 50%;
            left: 50%;
            margin-left: -100px;
            margin-top: -75px;
        }
        a{
            font-size:3em;
        }
    </style>
</head>
<body>
<div id="content" style="width:500px;height:500px;background:red;">
    这是被全屏的元素
    <div class="box">
        <button id='btn' style="width:100px;height:100px">全屏</button>
    </div>
</div>
<script>
    let ele = document.getElementById('content');
    let loadContent;
    ele.onload = function() {
        loadContent = 'load complete';
    };

    function test() {
        backToEts.test('backToEts');
    }

    function fullScreen(el) {
        let rfs = el.requestFullScreen || el.webkitRequestFullScreen || el.mozRequestFullScreen || el.msRequestFullScreen;
        let wscript;
        if (typeof rfs !== 'undefined' && rfs) {
            rfs.call(el);
            return;
        }
        if (typeof window.ActiveXObject !== 'undefined') {
            wscript = new ActiveXObject('WScript.Shell');
            if (wscript) {
                wscript.SendKeys('{F11}');
            }
        }
    }
    function exitFullScreen() {
        let el = document;
        let cfs = el.cancelFullScreen || el.webkitCancelFullScreen || el.mozCancelFullScreen || el.exitFullScreen;
        let wscript;
        if (typeof cfs !== 'undefined' && cfs) {
            cfs.call(el);
            return;
        }
        if (typeof window.ActiveXObject !== 'undefined') {
            wscript = new ActiveXObject('WScript.Shell');
            if (wscript != null) {
                wscript.SendKeys('{F11}');
            }
        }
    }

    let btn = document.getElementById('btn');
    let content = document.getElementById('content');//被全屏显示的元素
    btn.onclick = function() {
        if (btn.innerText === '全屏') {
            fullScreen(content);
            btn.innerText = '退出全屏';
        } else {
            exitFullScreen();
            btn.innerText = '全屏';
        }
    };

    function elementFullScreen() {
        let content = document.getElementById('content');
        return content.requestFullscreen();
    }

    function elementExitFullScreen() {
        document.exitFullscreen();
    }

    function checkIsFullScreen() {
        return !!(document.webkitIsFullScreen || document.mozFullScreen || document.msFullscreenElement || document.fullscreenElement);
    }

</script>
</body>
</html>